package com.ruoyi.web.controller.production.plug;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.domain.plug.PlugPurchaseApply;
import com.ruoyi.production.service.plug.IPlugPurchaseApplyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 穴盘购买申请Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/system/plugpurchaseApply")
public class PlugPurchaseApplyController extends BaseController
{
    @Autowired
    private IPlugPurchaseApplyService plugPurchaseApplyService;

    /**
     * 查询穴盘购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:plugpurchaseApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(PlugPurchaseApply plugPurchaseApply)
    {
        startPage();
        List<PlugPurchaseApply> list = plugPurchaseApplyService.selectPlugPurchaseApplyList(plugPurchaseApply);
        return getDataTable(list);
    }

    /**
     * 导出穴盘购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:plugpurchaseApply:export')")
    @Log(title = "穴盘购买申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PlugPurchaseApply plugPurchaseApply)
    {
        List<PlugPurchaseApply> list = plugPurchaseApplyService.selectPlugPurchaseApplyList(plugPurchaseApply);
        ExcelUtil<PlugPurchaseApply> util = new ExcelUtil<PlugPurchaseApply>(PlugPurchaseApply.class);
        return util.exportExcel(list, "穴盘购买申请数据");
    }

    /**
     * 获取穴盘购买申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:plugpurchaseApply:query')")
    @GetMapping(value = "/{plugPurchaseApplyId}")
    public AjaxResult getInfo(@PathVariable("plugPurchaseApplyId") Long plugPurchaseApplyId)
    {
        return AjaxResult.success(plugPurchaseApplyService.selectPlugPurchaseApplyById(plugPurchaseApplyId));
    }

    /**
     * 新增穴盘购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:plugpurchaseApply:add')")
    @Log(title = "穴盘购买申请", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody PlugPurchaseApply plugPurchaseApply)
    {
        return toAjax(plugPurchaseApplyService.insertPlugPurchaseApply(plugPurchaseApply));
    }

    /**
     * 修改穴盘购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:plugpurchaseApply:edit')")
    @Log(title = "穴盘购买申请", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody PlugPurchaseApply plugPurchaseApply)
    {
        return toAjax(plugPurchaseApplyService.updatePlugPurchaseApply(plugPurchaseApply));
    }

    /**
     * 删除穴盘购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:plugpurchaseApply:remove')")
    @Log(title = "穴盘购买申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{plugPurchaseApplyIds}")
    public AjaxResult remove(@PathVariable Long[] plugPurchaseApplyIds)
    {
        return toAjax(plugPurchaseApplyService.deletePlugPurchaseApplyByIds(plugPurchaseApplyIds));
    }
}
